%% FIGURE A-14
clear all
clc
% Add path 
% Determine where your m-file's folder is.
folder = fileparts(which("Figure_A_14.m")); 
% Add that folder plus all subfolders to the path.
addpath(genpath(folder)); 

% Saving path
file_dir = what('Figures'); 
spath=file_dir.path;

% Setting
hor1=10;
hor2=20;
jhor1=0:hor1;
jhor2=0:hor2;
Run_color_settings
% LOAD DATA
Results03=load("Results/AR1DGP_03.mat");
Results06=load("Results/AR1DGP_06.mat");
Results08=load("Results/AR1DGP_08.mat");

% Plot
clf
N_plot=3;
pln=1;
plotColumns=3;
figure(1)
for j=1:N_plot
            grid on
            pl=subplot(ceil(N_plot/plotColumns),plotColumns,pln);
            hold on
            
           if j==1
           % Average length
            p0=plot(jhor1,Results03.Results.AL.Pool.seqblock'./Results03.Results.the_rms_irf(1,1), '-','LineWidth',3,'Color', flexiblecolor); 
            p1=plot(jhor1,Results03.Results.AL.Pool.seqblock_bs1'./Results03.Results.the_rms_irf(1,1), '-o','LineWidth',3,'Color', blocksize1color); 
            p2=plot(jhor1,Results03.Results.AL.Pool.seqblock_bs2'./Results03.Results.the_rms_irf(1,1), '-square','LineWidth',3,'Color', blocksize2color); 
            hold off; axis tight
            xlim([0 hor1]);
            set(gca,'XTick',0:2:hor1,'XTickLabel',cellstr(num2str((0:2:hor1)')),'Layer','top','FontSize',14)
            xlabel('Horizon')  
            ylim([0.7 1.5]) 
            yticks(0.7:0.2:1.5)
            title('\rho=0.3','FontSize',16,'FontWeight','normal')
            %lh=legend([p0 p1 p2],{'Flexible block size';'Block size=4';'Block size=10'},'FontSize',16,'Location','northeast','Box','off');

           elseif j==2           
            p0=plot(jhor1,Results06.Results.AL.Pool.seqblock'./Results06.Results.the_rms_irf(1,1), '-','LineWidth',3,'Color', flexiblecolor); 
            p1=plot(jhor1,Results06.Results.AL.Pool.seqblock_bs1'./Results06.Results.the_rms_irf(1,1), '-o','LineWidth',3,'Color', blocksize1color); 
            p2=plot(jhor1,Results06.Results.AL.Pool.seqblock_bs2'./Results06.Results.the_rms_irf(1,1), '-square','LineWidth',3,'Color', blocksize2color); 
            hold off; axis tight
            xlim([0 hor1]);
            set(gca,'XTick',0:2:hor1,'XTickLabel',cellstr(num2str((0:2:hor1)')),'Layer','top','FontSize',14)
            xlabel('Horizon')  
            ylim([0.8 1.4]) 
            yticks(0.8:0.2:1.4)
            title('\rho=0.6','FontSize',16,'FontWeight','normal')
           % lh=legend([p0 p1 p2],{'Flexible block size';'Block size=4';'Block size=10'},'FontSize',16,'Location','northeast','Box','off');

           elseif j==3           
            p0=plot(jhor2,Results08.Results.AL.Pool.seqblock'./Results08.Results.the_rms_irf(1,1), '-','LineWidth',3,'Color', flexiblecolor); 
            p1=plot(jhor2,Results08.Results.AL.Pool.seqblock_bs1'./Results08.Results.the_rms_irf(1,1), '-o','LineWidth',3,'Color', blocksize1color); 
            p2=plot(jhor2,Results08.Results.AL.Pool.seqblock_bs2'./Results08.Results.the_rms_irf(1,1), '-square','LineWidth',3,'Color', blocksize2color); 
            hold off; axis tight
            xlim([0 hor2]);
            set(gca,'XTick',0:4:hor2,'XTickLabel',cellstr(num2str((0:4:hor2)')),'Layer','top','FontSize',14)
            xlabel('Horizon')  
            ylim([0.8 1.6]) 
            yticks(0.8:0.2:1.6)
            title('\rho=0.8','FontSize',16,'FontWeight','normal')
            lh=legend([p0 p1 p2],{'Flexible block size';'Block size=4';'Block size=20'},'FontSize',16,'Location','southeast','Box','off');
           end
            grid on
            ax = gca;             % Get current axes
            ax.GridLineStyle = ':';    % (Optional) Set grid line style
            ax.LineWidth = 2;         % This affects grid line thickness and axes box
            ax.GridColor = [0 0 0];
            x0=10;
            y0=10;
            width=1200;
            height=400;      
            pln=pln+1;          
            set(gcf,'position',[x0,y0,width,height])
            hold off
end
saveas(figure(1),fullfile(spath,['AR_blocksize_AL.eps']),'epsc');
